import request from "../http/axios";

export function getIndex(data) {
  return request({
    url: "/user/",
    method: "get",
    data,
  });
}

//实时数据初始化
export function relatimeInit(data) {
  return request({
    url: "api/oxygen/realtime/init",
    method: "get",
    data,
  });
}
//实时曲线初始化
export function relatimeCurve(data) {
  return request({
    url: "api/oxygen/realtime/curve",
    method: "get",
    data,
  });
}
//获取历史数据
export function history(data) {
  return request({
    url:
      "api/oxygen/history?start_time=" +
      data.start_time +
      "&end_time=" +
      data.end_time +
      "&time_unit=" +
      data.time_unit,
    method: "POST",
  });
}
//获取系统配置
export function getConfig(data) {
  return request({
    url: "api/oxygen/config",
    method: "get",
    data,
  });
}

//刷新串口
export function getPorts(data) {
  return request({
    url: "api/oxygen/config/ports",
    method: "get",
    data,
  });
}

//连接串口
export function postPorts(data) {
  return request({
    url: `api/oxygen/config/ports?dcs_port=${data.dcs_port}&oxygen_port=${data.oxygen_port}&connection=${data.connection}`,
    method: "post",
  });
}
//保存到csv文件
export function saveCsv(data) {
  return request({
    url: "api/oxygen/config/save",
    method: "post",
    data,
  });
}
